from django.db import models


class CustomeruserBindCardOrder(models.Model):

    ORDER_STATUS_CHOICES = (
        (1, '待支付'),
        (2, '已支付'),
        (3, '支付失败'),
        (4, '已退款'),
        (5, '退款失败')
    )

    BANK_TYPE_CHOICES = (
        (1, '邮储借记卡'),
        (2, '邮储信用卡'),
        (3, '其他')
    )

    customeruser = models.ForeignKey('users.CustomerUser', verbose_name='用户', on_delete=models.CASCADE)
    amount = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='支付金额', default=0)
    order_status = models.SmallIntegerField(verbose_name='订单状态', choices=ORDER_STATUS_CHOICES, default=1)
    bank_type_sign = models.SmallIntegerField(verbose_name='银行标识', choices=BANK_TYPE_CHOICES, default=3)
    description = models.CharField(verbose_name='商品描述', max_length=127)
    out_trade_no = models.CharField(verbose_name='商户订单号', max_length=32, unique=True)
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    user_received_account = models.CharField(verbose_name='退款入账账户', max_length=64, null=True, blank=True)
    refund_id = models.CharField(verbose_name='微信支付退款单号', max_length=32, null=True, blank=True)
    out_refund_no = models.CharField(verbose_name='商户退款单号', max_length=32, null=True, blank=True)
    transaction_id = models.CharField(verbose_name='交易单号', max_length=32)
    message = models.CharField(verbose_name='交易单号', max_length=128, null=True, blank=True)
    bank_type = models.CharField(verbose_name='付款银行类型', max_length=16, null=True, blank=True)
    success_time = models.DateTimeField(verbose_name='成功支付时间', null=True, blank=True)
    refund_time = models.DateTimeField(verbose_name='该笔交易的退款时间', null=True, blank=True)

    class Meta:
        db_table = 'tb_o_bind_card_order_customeruser'
        verbose_name = '绑卡校验订单'
        verbose_name_plural = verbose_name
